var e = require("../../@babel/runtime/helpers/regeneratorRuntime"),
  t = require("../../@babel/runtime/helpers/asyncToGenerator"),
  r = require("../../@babel/runtime/helpers/slicedToArray"),
  s = require("../../store/index"),
  a = require("../../utils/index").helper.tabCommon;
Page({
  useStore: function (e) {
    return {
      userLocationCity: e.storage.userLocationCity,
      searchHistoryLabelList: e.storage.searchHistoryLabelList
    }
  },
  data: {
    searchValue: "",
    guessLabelList: []
  },
  onLoad: function (e) {
    var t = this,
      s = a.getTabMode();
    $.request["GET/v2/mechanical/hots"]({
      source: "XCX",
      type: 1,
      mode: s
    }).then((function (e) {
      var s, a, n = r(e, 1)[0];
      null != n && null !== (s = n.content) && void 0 !== s && s.hots && t.setData({
        guessLabelList: null == n || null === (a = n.content) || void 0 === a ? void 0 : a.hots
      })
    }))
  },
  onCity: function () {
    $.router.push("/subpackage/common/multi-role-select/index", {
      type: "city"
    })
  },
  onSearch: function (r) {
    var a = this;
    return t(e().mark((function t() {
      var n, i;
      return e().wrap((function (e) {
        for (;;) switch (e.prev = e.next) {
          case 0:
            (n = r.detail.replace(/^(\s*)|(\s*)$/g, "")) && (-1 === (i = JSON.parse(JSON.stringify(a.data.searchHistoryLabelList || []))).findIndex((function (e) {
              return e.name === n
            })) && (i.push({
              id: $.getIndex(),
              name: n
            }), (0, s.dispatch)(s.actions.storageActions.setItem({
              key: "searchHistoryLabelList",
              value: i
            }))), $.router.push("/subpackage/machine-list-search/index", {
              keywords: n
            }));
          case 2:
          case "end":
            return e.stop()
        }
      }), t)
    })))()
  },
  onLabelPicker: function (r) {
    return t(e().mark((function t() {
      var s;
      return e().wrap((function (e) {
        for (;;) switch (e.prev = e.next) {
          case 0:
            (s = r.target.dataset.item).name && $.router.push("/subpackage/machine-list-search/index", {
              keywords: s.name
            });
          case 2:
          case "end":
            return e.stop()
        }
      }), t)
    })))()
  },
  onDesc: function () {
    (0, s.dispatch)(s.actions.storageActions.setItem({
      key: "searchHistoryLabelList",
      value: []
    }))
  }
});